/**
 * 消息通知
 * @author luguoxiang
 * @date 2023-03-29
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
import { createApi, request } from '@/soar';

export const basePath = '/system/notice';
export const subject = '消息通知';
const notice = createApi(basePath, subject);

export default {
  ...notice,
  /**
   * 读取消息
   * @param id
   */
  read: (id: any) => request.get(`${basePath}/read`, { params: { id } }),
  /**
   * 更新前用户消息为已读
   * @param ids
   */
  updateRead: (ids: any) => request.post(`${basePath}/update-read`, { data: Array.isArray(ids) ? ids : [ids] }),
  /**
   * 当前用户消息查询
   * @param params
   */
  currentUserNotice: (params: any) => request.get(`${basePath}/current-user-notice`, { params }),
  /**
   * 当前用户消息删除
   * @param ids
   */
  removeUserNotice: (ids: any) =>
    request.post(`${basePath}/remove-user-notice`, { data: Array.isArray(ids) ? ids : [ids] }),
  /**
   * 获取当前用户未读消息，为轮询设计
   * @param webCount 前端已知消息数量
   */
  unread: (webCount: number) => request.get(`${basePath}/unread`, { params: { webCount } }),
};
